package thread;

public class SynchronizedTest extends Thread {
    static volatile int a = 0;


    public static  void main(String[] args) throws InterruptedException {
        SynchronizedTest noSynchronizedTest = new SynchronizedTest();
        SynchronizedTest noSynchronizedTest1 = new SynchronizedTest();
        noSynchronizedTest.start();
        noSynchronizedTest1.start();
        noSynchronizedTest.join();
        noSynchronizedTest1.join();
        System.out.println(a);
    }
    public static   synchronized void add(){
            for (int i = 0; i < 10000; i++) {
                a++;
            }


    }
    @Override
    public void run() {
        add();
    }
}
